<?php
if (! defined ( 'BASEPATH' ))
	exit ( 'No direct script access allowed' );

class Authority {
	private $CI;
	function __construct() {
		$this->CI = & get_instance ();
		$this->CI->load->library ( 'mysession' );
	}
	
	function filter($role = SESSION_KEY_USER_ROLE_USER){
		log_message(ETS_INFO, '### Authority->filter');
		if($this->CI->mysession->hasLogin($role)){
			log_message(ETS_INFO, '### Authority: has login');
			return;
		}
		if(SESSION_KEY_USER_ROLE_ADMIN == $role){
			log_message(ETS_INFO, '### goto C:admin/login');
			redirect(site_url('admin/login'));
		}else{
			log_message(ETS_INFO, '### goto C:login');
			redirect(site_url('login'));
		}
		exit;
	}
}